import os,re
    
# 处理文件
def handler_file(path):
    file=os.path.basename(path)
    pre,suf = os.path.splitext(file)
    dst_file = None
    if re.search('[a-zA-Z]+-[\d]+',pre):
        m = re.search('[a-zA-Z]+-[\d]+',pre)
        dst_file = m.group(0)

    # xxx123
    elif re.search('[a-zA-Z]+[\d]+',pre):
        m = re.search('[a-zA-Z]+[\d]+',pre)
        org = m.group(0)
        rules = re.compile('[0-9]')
        ret = re.search(rules,org)
        idx = ret.span()[0]
        name = org[0:idx]   # xxx
        number = org[idx:]  # 123
        dst_file = name+'-'+number
        
    else:
        print("不能匹配文件规则")
        dst_file = pre
    
    dst_file = dst_file.lower()
    print("处理结果:",dst_file)

path=["free@xxx-111","hd-XXX-123","xxx123","xxx-123"]

for it in path:
    handler_file(it)